//
//  CustomSettingsTableViewCell.m
//  DriftDog
//
//  Created by rimi on 15/9/8.
//  Copyright (c) 2015年 廖马林. All rights reserved.
//

#import "CustomSettingsTableViewCell.h"

@implementation CustomSettingsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.iconImageView];  // 添加左边的icon
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.rightIndicator];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.iconImageView.center = CGPointMake(25 * DHFlexibleVerticalMutiplier(), self.bounds.size.height / 2);
    self.titleLabel.center = CGPointMake(100 * DHFlexibleVerticalMutiplier(), self.bounds.size.height / 2);
}

#pragma mark - getter

- (UIImageView *)iconImageView {

    if (!_iconImageView) {
        
        _iconImageView = [[UIImageView alloc] initWithFrame:DHFlexibleFrame(CGRectMake(5, 15, 30, 30), NO)];
        self.iconImageView.center = CGPointMake(25 * DHFlexibleVerticalMutiplier(), self.center.y);
        _iconImageView.backgroundColor = [UIColor clearColor];
    }
    return _iconImageView;
}

- (UILabel *)titleLabel {

    if (!_titleLabel) {
        
        _titleLabel = [[UILabel alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0, 0, 70, 60), NO)];
        
        _titleLabel.text = @"联系我们";
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = [UIFont systemFontOfSize:17 * DHFlexibleVerticalMutiplier()];
        _titleLabel.textColor = [UIColor colorWithWhite:90 / 255.f alpha:1];
    }
    return _titleLabel;
}

- (UIImageView *)rightIndicator {

    if (!_rightIndicator) {
        
        _rightIndicator = [[UIImageView alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0, 0, 15, 15), NO)];
        _rightIndicator.center = CGPointMake((ORIGIN_WIDTH - 20) * DHFlexibleVerticalMutiplier(), self.center.y + 13);
        _rightIndicator.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForAuxiliaryExecutable:@"向右指示器.png"]];
        _rightIndicator.alpha = 0.5;
    }
    return _rightIndicator;
}

@end
